package com.xxin.controller;

import com.github.pagehelper.PageInfo;
import com.xxin.pojo.dto.RegistryDTO;
import com.xxin.pojo.vo.RegistryVO;
import com.xxin.service.RegistryService;
import jakarta.annotation.Resource;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author 小欣
 * @version 1.0
 * @since 1.8
 */
@Controller
@RequestMapping("/api/register")
public class RegistryController {
	
	private final Logger log = LogManager.getLogger(RegistryController.class);
	
	@Resource
	private RegistryService registryService;


	/*
	分页查询挂号信息列表
	 */
	@GetMapping("/registerList")
	public String registerListGET(RegistryDTO registryDTO, Model model){
		PageInfo<RegistryVO> registryPageInfo = registryService.conditionPageQuery(registryDTO);
		model.addAttribute("registryList",registryPageInfo.getList());
		model.addAttribute("pages",registryPageInfo);
		return "registerInfoList";
	}
	
	@RequestMapping("/registerInfoList")
	public String registerInfoList(RegistryDTO registryDTO,Model model){
		log.info("查询的用户信息为:{}",registryDTO);
		PageInfo<RegistryVO> registryVOPageInfo = registryService.conditionPageQuery(registryDTO);
		model.addAttribute("registryList",registryVOPageInfo.getList());
		model.addAttribute("pages",registryVOPageInfo);
		model.addAttribute("queryIdCard",registryDTO.getIdCard());
		model.addAttribute("queryStatus",registryDTO.getStatus());
		model.addAttribute("queryDoctorId",registryDTO.getUserId());
		return "registerInfoList";
	}
	
	
	
}
